package models

import (
    "github.com/astaxie/beego/orm"
    _ "github.com/go-sql-driver/mysql"
    "shopping/models/order"
)

func init() {
	orm.RegisterModel(new(User),new(Product),new(Item),new(Itemnum),new(Order),new(order.MyOrder))
	//注册模型并使用表前缀
    //orm.RunCommand()
}

func Queryitems(uid int)([]orm.Params){
  o :=orm.NewOrm()
  var maps []orm.Params
  o.Raw("select it.id as itemid,pro.`name` as proname,pro.img as img,it.remarks as remarks,itn.num as num ," +
      "pro.price as price,itn.num * pro.price as total from item as it " +
      "left join itemnum as itn on it.id = itn.itemid " +
      "left join product as pro on it.pid = pro.id where it.flag =? and it.uid = ?", 0,uid).Values(&maps)
  return maps
}
